home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / lang / SmallEiffel.lha / SmallEiffel / lib_se / e_ensure.e < prev    next >
Text File  |  1998-12-22  |  4KB  |  166 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class E_ENSURE
  17.    --
  18.    -- To store a `ensure' clause.
  19.    --
  20.    
  21. inherit ASSERTION_LIST;
  22.          
  23. creation make, make_runnable 
  24.  
  25. feature 
  26.    
  27.    is_ensure_then: BOOLEAN;
  28.  
  29. feature
  30.            
  31.    name: STRING is
  32.       do
  33.      if is_ensure_then then
  34.         Result := "ensure then";
  35.         else
  36.         Result := "ensure";
  37.      end;
  38.       end;
  39.    
  40.    c_declare_for_old is
  41.      -- Produce C declarations for `old' expressions.
  42.       local
  43.      i: INTEGER;
  44.       do
  45.      if list /= Void then
  46.         from  
  47.            i := list.lower;
  48.         until
  49.            i > list.upper
  50.         loop
  51.            list.item(i).c_declare_for_old;
  52.            i := i + 1;
  53.         end;
  54.      end;
  55.       end;
  56.    
  57.    compile_to_c_old is
  58.      -- Initialization for `old' expressions.
  59.       local
  60.      i: INTEGER;
  61.       do
  62.      if list /= Void then
  63.         from  
  64.            i := list.lower;
  65.         until
  66.            i > list.upper
  67.         loop
  68.            list.item(i).compile_to_c_old;
  69.            i := i + 1;
  70.         end;
  71.      end;
  72.       end;
  73.    
  74.    compile_to_jvm_old is
  75.      -- If needed, add some more local variable to store the 
  76.      -- result of Eiffel "old".
  77.       local
  78.      i: INTEGER;
  79.       do
  80.      if list /= Void then
  81.         from  
  82.            i := list.lower;
  83.         until
  84.            i > list.upper
  85.         loop
  86.            list.item(i).compile_to_jvm_old;
  87.            i := i + 1;
  88.         end;
  89.      end;
  90.       end;
  91.    
  92.    short is
  93.       local
  94.      i: INTEGER;
  95.       do
  96.      short_print.hook_or("hook511","      ensure%N");
  97.      if header_comment = Void then
  98.         short_print.hook_or("hook512","");
  99.      else
  100.         short_print.hook_or("hook513","");
  101.         header_comment.short("hook514","         -- ","hook515","%N");
  102.         short_print.hook_or("hook516","");
  103.      end;
  104.      if list = Void then
  105.         short_print.hook_or("hook517","");
  106.      else
  107.         short_print.hook_or("hook518","");
  108.         from  
  109.            i := 1;
  110.         until
  111.            i = list.upper          
  112.         loop
  113.            list.item(i).short("hook519","         ", -- before each assertion
  114.                   "hook520","", -- no tag
  115.                   "hook521","", -- before tag
  116.                   "hook522",": ", -- after tag
  117.                   "hook523","", -- no expression
  118.                   "hook524","", -- before expression
  119.                   "hook525",";", -- after expression except last
  120.                   "hook526","%N", -- no comment
  121.                   "hook527","", -- before comment
  122.                   "hook528"," -- ", -- comment begin line
  123.                   "hook529","%N", -- comment end of line
  124.                   "hook530","", -- after comment
  125.                   "hook531",""); -- end of each assertion
  126.  
  127.            i := i + 1;
  128.         end;
  129.         list.item(i).short("hook519","         ", -- before each assertion
  130.                    "hook520","", -- no tag
  131.                    "hook521","", -- before tag
  132.                    "hook522",": ", -- after tag
  133.                    "hook523","", -- no expression
  134.                    "hook524","", -- before expression
  135.                    "hook532","", -- after expression except last
  136.                    "hook526","%N", -- no comment
  137.                    "hook527","", -- before comment
  138.                    "hook528"," -- ", -- comment begin line
  139.                    "hook529","%N", -- comment end of line
  140.                    "hook530","", -- after comment
  141.                    "hook531","");
  142.         short_print.hook_or("hook533","");
  143.      end;
  144.      short_print.hook_or("hook534","");
  145.       ensure
  146.      fmt.indent_level = old fmt.indent_level;
  147.       end;
  148.  
  149. feature {EIFFEL_PARSER}
  150.  
  151.    set_ensure_then is
  152.       do
  153.      is_ensure_then := true;
  154.       end;
  155.      
  156.    
  157. feature {NONE}
  158.    
  159.    check_assertion_mode: STRING is
  160.       do
  161.      Result := "ens";
  162.       end;
  163.    
  164. end -- E_ENSURE
  165.  
  166.